package com.wms.core;

import com.wms.bean.ResultBean;
import com.wms.constant.HttpCode;

public class R {

    public static <T> ResultBean success(String msg,T data){
        return  handler(HttpCode.SUCCESS,msg,data);
    }
    public static <T> ResultBean success(String msg){
        return handler(HttpCode.SUCCESS,msg,null);
    }
    public static <T> ResultBean fail(String msg){
        return handler(HttpCode.FAIL,msg,null);
    }
    public static <T> ResultBean fail(String msg,T data){
        return handler(HttpCode.FAIL,msg,data);
    }
    /**
     * 保存结果
     *
     * @param rs
     * @return
     */
    public static ResultBean saveResult(int rs) {
        return rs == 1 ? success("保存成功") : fail("保存失败");
    }
    static <T> ResultBean handler(int code,String msg,T data){
        return new ResultBean(code,msg,data);
    }
}
